<link rel="stylesheet" type="text/css" media="all" href="../css/validate.css" />
<link rel="stylesheet" type="text/css" href="../css/start/jquery-ui-1.8.13.custom.css" /> 
<style type="text/css"> 
body { font-size: 62.5%; }
label { display: inline-block; width: 100px; }
legend { padding: 0.5em; }
fieldset fieldset label { display: block; }
</style> 
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.13.custom.min.js"></script>
<script type="text/javascript" src="../js/jquery.validate.min.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/ajax.js"></script>
<script type="text/javascript">
<%
        out.print("var accion='" + request.getParameter("accion") + "';\n");
		out.print("var id='" + request.getParameter("id") + "';\n");
%>
</script>
<script type="text/javascript">
$(document).ready(function() {
	$("input:button, input:submit").button();
	
    $('<div>').attr('id', 'loading').append(
            $('<img>').attr('src', '../images/ajax_loading.gif').attr('alt', 'Cargando...')
          ).css({
              position: 'fixed',
              display: 'none'
          })	
          
	if (accion == 'editar') {
		$('#titulo').html("Modificar");
		$("#divFormGerencia").show("slow", function(){
			editarGerenciaLVS2(id);
        });		
	} else if (accion == 'agregar') {
		$('#titulo').html("Agregar");
		$("#divFormGerencia").show();			
	}

    $("#gerenciaForm").validate({
	    rules: {
			nombre: { required: true, minlength: 2 }								
	    },
	    messages: {
	    	nombre: "ingresar un nombre para la gerencia"
	    },
	    errorElement: "div",
	    wrapper: "div",
	    errorPlacement: function (error, element) {
	        offset = element.offset();
	        error.insertBefore(element);
	        error.addClass('message');
	        error.css('position', 'absolute');
	        error.css('left', offset.left + element.outerWidth());
	        error.css('top', offset.top);
	    },
	    submitHandler: function (form) {
			var formInput = $('form[id$=gerenciaForm]').serialize();
			if (accion == 'editar') {
				actualizarGerenciaLVS(formInput);
			}else if (accion == 'agregar'){
				guardarGerenciaLVS(formInput);			 
			}
	    }     
	});	 
});
</script>	
<body>	
<div id="divFormGerencia" style="display:none;">  
<form id="gerenciaForm">
<input type="hidden" name="id" id="id" value=""></input>
<fieldset class="ui-widget ui-widget-content ui-corner-all">
<legend class="ui-widget ui-widget-header ui-corner-all" id="titulo"></legend>  
<p><label for=nombre>Nombre:</label><input type="text" name="nombre" id="nombre" size="50" /></p>
<br>
<p style="text-align:center"><input type="submit" name="submit" id="submit" value="Guardar"/></p>
</fieldset>
</form>
</div>
</body>  